<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org"
      th:replace="~{admin/layout :: html(title=${title}, content=~{::content})}">
<head>
    <title>产品管理</title>
</head>
<body>
    <div th:fragment="content">
        <div th:if="${message}" class="alert alert-success" th:text="${message}"></div>
        <div th:if="${error}" class="alert alert-danger" th:text="${error}"></div>

        <a href="/admin/product/add" class="btn btn-primary mb-3"><i class="fas fa-plus"></i> 添加新产品</a>
        
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>名称</th>
                    <th>分类</th>
                    <th>价格</th>
                    <th>库存</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <tr th:each="product : ${products}">
                    <td th:text="${product.id}"></td>
                    <td th:text="${product.name}"></td>
                    <td th:text="${product.category}"></td>
                    <td th:text="${product.price}"></td>
                    <td th:text="${product.stock}"></td>
                    <td th:text="${product.status}"></td>
                    <td>
                        <a th:href="@{/admin/product/edit/{id}(id=${product.id})}" class="btn btn-sm btn-warning"><i class="fas fa-edit"></i> 编辑</a>
                        <a th:href="@{/admin/product/delete/{id}(id=${product.id})}" class="btn btn-sm btn-danger"
                           onclick="return confirm('确定要删除这个产品吗？');"><i class="fas fa-trash"></i> 删除</a>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</body>
</html> 